You just need to fix the formulae I gave, to cover for below thresholds also.

Try using ABS()