JS Coderefactoring