Adds undo functionality (can only undo once)