refactor js files