main function finished