Added another small optimization to backtracking