Missing Encoder Steps

Anyone have any suggestions on how to implement the z index into my current code?