fix some bugs in computing the similarity