your solution fails trying to pop from empty queue