An exmaple of flatMap implementation