improved response handling