undo function with complete