refactored into two classes