undo loop fix