move the setting of context.whenTriggered into trigger method