main.py improved