added gain argument