fixed removing item at the incorrect time