bug fix in main.c