add caching for query parser
optimize code