refactored script.js. long lines