adding the document index when there is an error