r2281 fix bug by closing query before opening new one