Fixing logic error in StoreSensorData when looking at the range of time
to store data.