Solving problem 2