fix error if device = None