Modifying the genetic algorithm for edge case