history-substring fix