fix response handling when errors occur