solving problem 6