bug fix in main.cpp