Js Refactoring