destruct method for Query