fixed a bug that led to duplications of items under certain circumstances