Added more comments and formatting to script.js