Refactor distance formatter.