tidied up pa5.py