problem 2.38: first draft complete