break down main.c into smaller pieces