added the cdist function