moved delivery.on listeners out of the for loop