got the undoCounter function to work properly (back-end), but still missing something with the front-end function of replacing text or whitespace with value from the undo array