updated device.py