}}}
I've given up on trying to help people that post code like this. If you put each { and } on separate lines, and use Tools + Auto Format, you may see what is wrong with the logic of your program. If not, post it again.
Removing useless { and } would be a good idea, too.
Finally, global and local variables of the same name is a sure recipe for disaster. You absolutely need to stop doing that.