Fix problem with inserting into join table