Fix bug when used with associations