Finally fully working JS-distances!