refactor distance as advance