re-adjusted the exponential gain so that it works with negative inputs as well