optimized dequeue