finished device.py