refactoring jscript
refactoring jscript and fixing bugs in parsing