ex20.py updated and finetuned