fixed small bug with distance