a few functions for calculating cluster distances