refactoring to use OO style