fixed index.html to run each loop properly