bfs with map