start refactoring the js file