Refactoring js files