use generators for iterating the cursors