Refactoring JS with OO