Organizing the loops was a little tricky