added average variable