fixed the problem of generation counting. it is correct now