this can be pulled out of this function (if queue is defined higher as well.