refactored api routes