fix if item category doesn't belong to the last category