a wee bit of refactoring