Refactors #linear_distance