Fix many to many relation routine