updated sod calculation code