solving problem 3