fixed some bugs in code for api routes.