js refactoring 1