refactoring factory and controllers