refactor new and update method