changed index2 to index