bfs with weighted distance working a lot better