add a null check to prevent linq error