bfs finally works