rebuild query