refactored sql group requests