refactored API routing