replace some list comprehensions with generators