Fixed some for loop errors in the item code