added BFS method and did a little improvement to DFS