working example 4
vastly improved ch07/04