Implement DFS