Error checking to prevent crash on null strings.