Refactored dynamic api controller.