added gain control