working distance function