problem 5 optimisation