Refactoring factory class