Add back tracking to solving algorithm.