code cleanup and updation for undo