refactored to class design