refactor js file