solving problem 2