rewrite core main.py