making response handling more robust