Fixed missing variable declaration

Variables are now declared before they are used. This allows the
code to run in strict mode.