hudge refactoring for better management of factories