You haven't posted enough code for anyone to know for sure what the cause is. In any event, the code in the link I posted does not suffer the defect you mention.