complete (untested) framework for update function.