Improved /api code