> Why didn't you answer my question?
Because there's no way to tell whether that's the real question, because you didn't post the real code.
Paraphrased code is absolutely NO use for debugging since there is NO way to tell whether you've missed some critical detail.
Hence it is simply a waste of both your time and mine to even look at code which you've pasted from memory and neither compiled or run.