fixed dfs bugs