untangle nested comprehension by using intermediate vars