Simplify the main function