why not overload the dispatchEvent instead of changing a large amount of lines?