added check the distance of the last position