Improving main.c flow