refactored to a two-class implementation