Moved the device id search into a separate method.