corrected evolve function