Use numpy arrays for distance calculations