chapter 5: exercise 7 - flatMap