script.js code tidy