Bug fixed for main.cpp