trying to fix api error handler