i have fixed it by using reverse for each loop instead of for each loop. not sure how it fixs it but it does.