before implementing the BFS