Update main.cpp and fixing