changed generate_ func