modified ex17.py