solving problem 4