bfs function has been added.