Refactor before_update method