Correct z axis calculation error