fix for AttributeError: 'NoneType' object has no attribute 'items'