Fast grouping function scripted