refactoring factory builder code