refactoring to be more OO