Replaced n list comprehension with generator