make update data in a function