Update script.js

added repair function