Made the genetic optimization code work