To help you it's neccesary to read the code in your problematic function to spot the cause of the problem.