Hi Miran,
This appears to be a request for 1-on-1 assistance with a coding question specific to your development. This isn't the right forum to look for help on such a question, which is perfectly suited to stackoverflow.com. This forum, on the other hand, is meant for more general high-level discussions of the platform and services, design patterns, etc.
As for how to assist you with the request itself, I will need you to post a minimal working example of your code with an example of the output you would like to generate.