Updated 2 to a generator function