Put all the codes into the same file, and then click the [{}] button in the top right of the code window. You will see that your brackets don't match up properly. Correct the brackets, and your code should work.

-genius_at_work