find a bug in main function