Modified based on exercises for ch. 5