Simplify main function