Automate the boring stuff for loops

Automate the boring stuff for loops