Fix backtracking stop condition