anchor.diff:  		return JSON.decode(inventory_json);
   	}
   
  +	bool _durabilityOk(Slot slot) {
  +		if (!slot.metadata.containsKey('durabilityUsed')) {
  +			return true;
  +		} else {
  +			int used = int.parse(slot.metadata['durabilityUsed'], onError: (String source) => 0);
  +			int max = items[slot.itemType].durability;
  +			if (items[slot.itemType].durability == null) {
  +				return true;
  +			} else {
  +				return (used < max);
  +			}
  +		}
  +	}
  +
   	// Returns the number of a certain item a user has
   	int countItem(String itemType, {bool includeBroken: true}) {
  -		bool _durabilityOk(Slot slot) {
  -			bool hasDurability = slot.metadata["durabilityUsed"] != null;
  -			if (!hasDurability) {
  -				return true;
  -			} else {
  -				int used = int.parse(slot.metadata["durabilityUsed"]);
  -				int max = items[slot.itemType].durability ?? 0;
  -				return (used < max);
  -			}
  -		}
  -
   		int count = 0;
   
   		//count all the normal slots
   		slots.forEach((Slot s) {
  -			if (
  -				(s.itemType != null && s.itemType == itemType)
  -				&& (includeBroken || _durabilityOk(s))
  -			) {
  +			if (s.itemType == itemType	&& (includeBroken || _durabilityOk(s))) {
   				count += s.count;
   			}
   		});
  
positive.code: 				List<Slot> bagSlots = jsonx.decode(s.metadata['slots'], type: listOfSlots);
  				if (bagSlots != null) {
  					bagSlots.forEach((Slot bagSlot) {
  						if (
  							(bagSlot.itemType != null && bagSlot.itemType == itemType)
  							&& (includeBroken || _durabilityOk(bagSlot))
  						) {
  							count += bagSlot.count;
  						}
  					});
  
negative.code: 	}
  
  	static Future<bool> hasItem(String email, String itemType, int count) async {
  		return (await takeAnyItemsFromUser(email, itemType, count, simulate:true)) >= count;
  	}
  
  	static Future<bool> hasUnbrokenItem(String email, String itemType, int count) async {
  		InventoryV2 inv = await getInventory(email);
  		return (await inv.countItem(itemType, includeBroken: false)) >= count;
  	}
  
  	/**
  