code clean up in main.cpp