rewrite and fix rating.js