added query handling code 1st cut