revised after before function on events