third - a bit better coding, except for the for loops