* move away SQL guts from parseQuery to queryMain