Some changes to handle response errors