js coderefactoring