refactored run.py to simplify my code -- added some comments