fixed bug in similarity function