Fixed bug in QueueTrended function