Refactoring vw_distance