Could you provide a minimal working example?
I would also suggest you to use 3x` encapsulation (mardown syntax) to encapsulate your code and make it more readable to other users.
For further information on how to post a question, you can read the community guidelines.