optimize queue