the newest version of main program,not tested.