Change dispatchevent to dispatchEvent