Fixed error in adding document to index