Changed AttributeError exception to NameError exception