Revise this to check  the d(3) AND ensure that $type->{'smell'}->{'option'} is defined, that way later on you can get rid of the "nothings" in the XML as well as the checks for "nothing".