corrected check for undefined names; try to avoid using "" for this as that is an empty name which is not the same as an undefined name though they often signify the same