added comments and formatting to script.js