finished problem 40