updated script

added event checking