handle query