Func restart and input

Add new algoritm in main().