fixed a major bug in mst dist calculation