refactor update insert