Refactored choosing of devices