refactor QueryService