implement as DFS, not done yet