Added random choosing when there's no optimal solution.