refactoring to OO