Implementing the sensor callback