fixed pointer de-allocation bug in main.c