refactor main.py