js file refactoring