Refactoring js.