Refactoring to objects