did some optimization on queues