changed cursor.each to be lazy (not hold all the items)