updated backtracking