Refactor Javacscript.