updated kernel to use cosine distance