bugfix distance metric