cleaned up query parser