added some logic to handle the error on query parsing