add backtracking for dfs bugs