refactored update() into separate methods in same file