fix distance calculator