update function js