changed averaging accordingly