Fix where docIndex is incremented