added sonar and distance-keeping functions