Split select_sensordata and implement grouping.