added transaction to prepare query for device unregistration