fixed bug in dfs