cleaned device.py