keep track of z indices