Implemented DFS