and yet more refactoring