implement error checking version for HC-SR04