JS Refactor