refactored update method