a lil bit shorter version of ex17.py