Fixed #23968 -- Replaced list comprehension with generators and dict comprehension