Improved DFS