Regroup and optimize code (run groups and updateResults function)