Refactored API Controller