refactor of updating