A little more refactoring to make the factory more reusable