refactory run.py