updated n_variables to represent actual numbers of aggregations