adding lock/unlock functionality to event handler to prevent changes while iterating
adding lock/unlock functionality to prevent alterations while iterating