Refactoring Js