Remove function declaration from block to allow strict mode

Apps that depend on this module cannot run with the `--use_strict` flag due to the use of a function declaration within the body of an `if` statement.