a bit of refactoring as we go