added average funcitonality