fixed distanceX inappropriately being calculated