Fix bug when similarity scores are negative