Implemented Undo functionality