forgot to reset the index each iteration