Cleaning code + returning a value even when the sensor data is not valid