During the Warring States Period (475-221 BC), the State of Chu was not very powerful. Its king and key officials were dissolute and incompetent, indulging in luxury and pleasure. Minister Zhuang Xin foresaw the danger and remonstrated with the king: "Your Majesty, you are surrounded by flatterers who distract you from state affairs. If this continues, the country will surely perish."
The King of Chu flew into a rage, accusing Zhuang Xin of cursing the state and stirring resentment. Zhuang Xin explained he had a premonition of great danger. Seeing the king's trust in corrupt officials, Zhuang Xin believed Chu was doomed and requested leave to go to the State of Zhao. The king agreed.
Five months later, the State of Qin invaded and occupied a large tract of Chu's territory, forcing the king into exile. Remembering Zhuang Xin's words, the king summoned him back and asked, "What can I do now?"
Zhuang Xin replied, "It's not too late to mend the sheepfold after a sheep is lost." He then offered suggestions to rehabilitate the state and recover the lost land, which pleased the king greatly.
The idiom "Mend the fold after a sheep is lost" originates from this story. We still use this metaphor to advise that even after a mistake and loss, one can still remedy the situation by learning from it.