Finish queue_next function