refactoring to OOP