fix dissimilarity algorithm