Fixed problem with multiple calls to chain variable

In certain cases, if a chain was called multiple times,
only the first link in the chain would be executed.