updated with cosine similarity code