Update script.js

Fixed issues with repetition and worked out final kinks.