fix a bug in the trigger handling code