Restructure the main.c
Restructure the code