working version of new gain control design