added the cos distance