refactored for object-orientation