started to rewrite the entire z-adjust operation