Fixing the bug in query handling.