using the patch in misc/distance.rb