moved generator logic into Lambda