Update scale.js

upgrade this code