refactoring js.