refactored script.js