add while for dequeue