Refactor totalRatings to fix bug on loading