solving problem 5