refactor io; add --query <sensorid> option