added average calculation