Distance function now breaks into coordinates