need to keep variables within link function scope