Added form data grouping function