adding Z and p variables