refactored method to objects