Added in dispatchEvent function