changed delay to use process function instead of direct events