Converted a list comprehension into a generator expression in query_utils.py