replaced takeFirst() with dequeue() for consistency