up to rand flatMap Ex. 6.8