refactoring on js files