added error catching so that no request is left pending (hopefully)