has_and_belogns_to_many implementation