fix bug in snippet of flatMap