Solving problem 6