added the generator logic