begin bfs