fixed a few problems with the sensor reading