replaced event.wait() by queue.finish()