Solving problem 8