split up logic for generator