added metric option for calculating distances