fixed foreign key is now used, before it was always incorrectly assumed to be "id"