So, you have some expectations. You have some code that does something. What it does isn't exactly clear. What is clear is that what it does isn't in line with your expectations.
So, I'll ask again. Where are your debug statements? Where is your debug output?