implemented error handling with proper response object