Update main.py

Improve performance