move distance.js to frontend libraries