Fixed seg fault in main.cpp