Replaced for-loop with list comprehension