refactor association related code