calculate and store average rating