Update main.py

some improvements