commiting cosine similarity function