Better tree construction with maximum distance