refactored controller factory