refactor avarage_rating method