imporved JS for index