You don't done anything with S0 after this, I suspect you meant to multiply the return value by S0 to scale the signal.