See this, you can adapt the code