moved js in loop