refactoring to more oo style