add compute_distance method and refactor similarity criteria