refactoring api routes