start the main while loop for bfs