clean up code in main.c