added auto backtracking