calculate next generation