Attempted to improve efficiency of zavg calcs