Developing algorithm to average spectrums