cleaning up main.c code