change code of flatMap