factored out association code into a function