move code in main.c