split up queue code