function to update rows