Minor optimization to dispatchEvent logic