updated to produce group averages (to be used for plotting)