translating for comprehahsion into flatmap