implementing DRY code using OOP