Fixed bug in cosine similarity computation