fix empty queue bug