refactoring out API routes