bugfix
optimize dfs