better error handling for deleting a document from index.
()
simplified