Final main function