moved to raw query for device ids