Simplify the main function.