query handling added