rewrote parseQuery