using the state of a sensor