Hi netbar!
Sameer is right - help us to help you. If you stripped out the unused code, indented the IF's and LOOP's, used a code tag, etc, it would be much easier for someone to spot the problem - including you!