replace simple loop with list comprehension