refactoring factory