finished problem 3.51