add error processing in main.py