extracted common code from gain and lowpass