Fix function definition for strict mode

Strict mode complains about function definition within if block.