Added a generator function