make collect a function, not a generator