Format your code using tabs. This will make it a lot easier for you to tell where you have missing (or misplaced) closing braces.

The general convention is for each new block (anything surrounded...