method invoke as a generator