POOR solution to problem 5 - needs reviewing