main.py file refactored