and bfs works