fixed a bug where there was no foreign key in one case