refactored into classes, part 1