changed to use macro instead of function for distance, using fast_distance