Update and fix bug for main.cpp