make distance metric converion into function