fixed query initialization bug