fixed bug in cosine normalization