complete dfs but need refactor