prevented memory leak in main.cpp