almost cleaned mainc.c