js refactor step1