Adding JS functions. Loop still not functional