sensor data hangs when going through if/then statements