make jarpat / distance metric function dynamic