generator logic, minor changes