Update Javascript loops