refactory QueryService