optimized version of the exponential function