Fix response format and error handling