Solving problem 4