fixed the i value of the last 2 iteration