fixed the problem of DFS algo