Quick fix for some runtime errors

Fixed "SyntaxError: in strict mode code, functions may be declared only
at top level or immediately within another function"