refactor user association code