updated run.py to be more reliable