Proper scoping 4 for loops, switch in next commit