, BitFlipper wrote

We are not seeing all of the code so we can't answer that question.

And therein lies the problem.

If someone asks a question about "why does my code not work" without providing at least an example that demonstrates the problem, the only option we have is to try psychic debugging to solve it.

If the OP wants it fixed, s/he needs to post an example that demonstrates the problem s/he's trying to solve.