Implemented defensive calculations.