Added min distance heuristic