How to group statistics in LOOP