The loop( ) method looks much cleaner now, because the program’s main functionality has been moved to separate functions. The whole sensor control logic lives in the measure_distance( ) method and output_distance( ) takes care of outputting values to the serial port. The big changes happened in the microseconds_to_cm( ) function. It returns a float value now, and it subtracts the sensor gap from the measured duration. To make sure we do not get negative values, we use the max( )function.