Fixed bug in DFS