Fixed previousState to show state only and better undo. No need to check canUndo flag