optimization on scope.js