update the main function