1. You can't define a function inside another function
2. That semicolon at the end of the line makes it a declaration, and so the braces with code in them are just more code to execute. Did you not notice that you couldn't use n and p?