bug fix for null foreign key