Simplify Scala code using for-comprehension instead of ugly match case (again)