handle_response code updated