fix bug in pop() to decrement counter