Completed the genetic algorithm