updated triggers to implement loops to support concurent transactions