refactoring to compile with asm.js and closure