modification to group matrix : prune