Refactoring run.py