refactored API control