js refactoring 3