adding cosine similarity function