updated cosine similarity script