Fixed a bug in device selection.