added bfs method