update z_diff logic