Handin 4. Exercise 2 solution