Problem 7 -- minor optimisation