A bit of refactoring to think this through