optimize for distance