I think your for loop is wrong. I changed something for your for loop, hope it will meet your requirment:

(spoonfeeding deleted by KevinWorkman)