Created a new script.js module, refactored code to use it