Refactored controller factory creation