Fix a bug when retrieving devices by did