move distance computation to distance.js