distance bugfix