fix cosine similarity