refactoring js
great refactoring