trying to refactor this thing into separate classes.