removed counter logic in DFS