distance bug fix