looping on triggered events until all done
extracted process functions from main