Changed problem 8 solution slightly.