modify ag_insert_enter_leave