refactoring to add a abstract factory