fix main function