Fixed bug with deleting documents