improved .py file