some factory refactoring