cleaned up main.c a bit