better main function