implementing similarity measures