Solving problem 3