add division by 0 protection to divergence