refactoring query_sensors