Added check to avoid side effects when updating item ids