Bugfix to get average Z.