added for loops in main.cgi that got stomped in commit.