fixed bug in similarity calculation