Rewrote script.js in order to keep it clean