Refactoring to use OOP