updated trigger code