Fixed AttributeError bug