Removes Code Repetition, corrects the count of groups.