refactor jscript