modify for loop
page wrap fixes