Fixed dfs bug