Refactor each-loops (exercises 6, 7 & 8)