Don't worry about it, with more practice you will get better at spotting errors.
What tipped it of here is I noticed that The open line is practicaly the first line with the variable in that procedure (click event), and just before that it is fine. So there is not code in between to mess it up, it must be something else. The declaration.