find the shortest distance for the location needed