modified insert method and main.cpp