Building code to handle for loops