updated generation alg.