update distances