Updated z logic again