added z handling
further elaboration