Refactor js files