private function updateStatus($unsentRegIds, &$allResults, MulticastResult $multicastResult) {
    $results = $multicastResult->getResults();
    if(count($results) != count($unsentRegIds)) {
      // should never happen, unless there is a flaw in the algorithm
      throw new \RuntimeException('Internal error: sizes do not match. currentResults: ' . $results .
        '; unsentRegIds: ' . $unsentRegIds);
    }

    $newUnsentRegIds = array();
    for ($i = 0; $i < count($unsentRegIds); $i++) {
      $regId = $unsentRegIds[$i];
      $result = $results[$i];
      $allResults[$regId] = $result;
      $error = $result->getErrorCode();

      if(!is_null($error) && $error == Constants::$ERROR_UNAVAILABLE)
        $newUnsentRegIds[] = $regId;
    }

    return $newUnsentRegIds;
  }