refactor average_rating method