Why don't to post the code - or at least the cursor and the begining of the loop?
Can we see the rest?
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman