Undo and Redo problem in Canvas

I am making a drawing app.
I have undo and redo problem in canvas.
I am using the undo and redo of Scott (https://groups.google.com/g/app-inventor-developers-library/c/yF2Auslt82M/m/e-9D1gSIS78J).
Problem :-

  1. The undo and redo button is not working properly
  2. I have to click more than 1 time to undo an action ,etc.

Screenshot :-


Apk - UndoRedoProblem.aia (5.5 KB)
AIA - UndoRedoProblem.aia (5.5 KB)

I have searched all over the community but I didn’t find any result.
Thanks in advance.

Post a screenshot of your relevant blocks.

does the original project work for you without that issue?
if yes, compare the blocks until you find the issue in your blocks…

I just copy and pasted the blocks and created some more blocks like when canvas1.touced

this does not answer the question