modified for main function generation