replaced loop with list comprehension