custom cls distance matrix