use more elegant flatMap and for comprehension