move logging into better place for average calculation