Fix the bug where if undo command is the first command on starting the program, the program will crash.