solving problem 22