Check the name is not null before trying to check it.