minor change on finalize function, cal average or not