Improve similarity calculator