implemented cosine similarity