Fixing bug in cosine similarity computation