Minor refactor DFS BFS