Fixed distance calcultaion bug.