attempt to refactor into classes