add protection for zero values in divergence