how margin of safety is calculated