[ fix ] possible invalid device index