added avg_rating updating function