Last generation algorithm