rewrote query parser