generator logic