finished draft of selection and aggregation