updated average calculation