code for z-dispersion