added function to calculate average rating of comments