moved js code into index