DFS & BFS
refactoring DFS & BFS