Fixed probable logic error in addEvent_replace()