tidy up problem 6