Improves handling of data formats and error response