fix: distance function, type compatibilities