BFS method