add option for cosine distance