Added new function to group top factors.