updated script1.js to remove infinite loop