improve Device.query