added divergence calculation