Dynamically choosing the main function