generic update method