refactored js on 'index.html'