Rewrite of distances