shortened hw3_2.py