Exercise 4.75 - slight refactoring for special uses of flatmap