Refactoring to obejcts