modified ex16.py