add logic to support multi devices.