Replace a for-comprehension by the equivalent calls to flatMap, map, withFilter, and foreach.