extract habtm handling to a method