_gen optimization stage 2.