replace for-comprehension with flatMap