revise and correct similarity algorithm
Merge branch 'similarity'