trying to resolve memory leaks: added free at the end of main.c