updated averaging method