new version of generateNewPopulation function