fix genetic algorithm and make it stop with stagnation