fix the crash in main.cpp