bfs seems to work