better error checking for deleted doc