refactored for object orientation