factory refactoring.