add curlies to avg loop