rearanged main.c