template for main function