Fix the problem that substitutes the event ID in the wrong variable by mistake.
Clean up with a helper function.