small improvement in DFS